|
|
|
|
|
|
|
Figure 7.8
The Color dialog box lets the user
select a color graphically and then
returns it to your program as a hex value. |
|
|
|
|
|
|
|
|
Setting up the CommonDialog control for colors is basically the same as for fonts. You set the Flags property to the constant cdlCCRGBInit and then invoke the control's ShowColor method. |
|
|
|
|
|
|
|
|
When the user selects a color from the dialog box, a hexadecimal number representing that color is stored in the Color property of the control. To see how the Color dialog box works, replace the code in the test project's cmdTest_Click event procedure with the following: |
|
|
|
|
|
|
|
|
cdlTest.Flags = cdlCCRGBInit
cdlTest.ShowColor
Form1.BackColor = cdlTest.Color |
|
|
|
|
|
|
|
|
As with the other dialog boxes, you can alter the behavior of the Color dialog box by using the Flags property. For example, if you want only default colors available, use the cdlCCPreventFullOpen flag so that the user cannot open the Define Custom Colors window. Check the Color Dialog Box/Flags Property (Color dialog) topic in the Visual Basic Help system for a full listing of the flags and properties that affect the Color dialog box. |
|
|
|
|
|
|
|
|
Another type of dialog box that the CommonDialog control can display is the Print dialog box. A Print dialog box is usually displayed just before your application initiates a printing process. It lets the user select which printer to use and specify options for the print process (see Figure 7.9). These options include specifying which pages to print and the number of copies, as well as an option of printing to a file. |
|
|
|
|
|
|
|
|
Figure 7.9
The Print dialog box provides a consistent
way for your users to set printer options. |
|
|
|
|
|